<template>
  <div>
    <div class="re-title">热销推荐</div>
    <ul>
      <!--border-bottom解决列表之间一像素边框-->
      <router-link
        tag="li"
        class="re-item border-bottom"
        v-for="(item) in recommentList"
        :key="item.id"
        :to="'/detail/' + item.id"
      >
        <!--使用div标签包裹img是为了撑开这个图片防止抖动-->
        <div class="re-item-img-wrapper">
          <img class="re-item-img" :src="item.urlImg" alt />
        </div>
        <div class="re-item-info">
          <p class="re-item-title">{{item.title}}</p>
          <p class="re-item-desc">{{item.desc}}</p>
          <button class="re-item-button">查看详情</button>
        </div>
      </router-link>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'HomeRecommend',
  props: {
    recommentList: Array
  }
}
</script>

<style lang="stylus" scope>
@import '~@/assets/styles/mixins.styl';

.re-title {
  margin-top: 0.2rem;
  line-height: 0.5rem;
  background: #eeeeee;
  text-indent: 0.2rem; /* 将段落的第一行缩进4px */
}

.re-item {
  overflow: hidden; /* 将溢出部分隐藏 */
  display: flex;
  height: 1.9rem;

  // background: red;
  .re-item-img-wrapper {
    width: 1.9rem;
    height: 1.9rem;

    .re-item-img {
      width: 1.7rem;
      height: 1.7rem;
      padding: 0.1rem;
    }
  }

  .re-item-info {
    flex: 1; /* 让所有弹性盒模型对象的子元素都有相同的长度，且忽略它们内部的内容： */
    padding: 0.1rem;
    min-width: 0; /* 设置段落的最小宽度 */

    .re-item-title {
      line-height: 0.54rem;
      font-size: 0.32rem;
      ellipsis();
    }

    .re-item-desc {
      line-height: 0.5rem;
      color: #cccccc;
      ellipsis();
    }

    .re-item-button {
      background: #ff9300;
      padding: 0 0.2rem;
      border-radius: 0.1rem;
      margin-top: 0.2rem;
    }
  }
}
</style>
